//
//  ReadCell.swift
//  Spookiness
//
//  Created by 腾億 on 2017/12/21.
//  Copyright © 2017年 tml. All rights reserved.
//

import UIKit
import Kingfisher
class ReadCell: UICollectionViewCell {
    
    fileprivate lazy var imageView: UIImageView = {
       let imgV = UIImageView()
        imgV.contentMode = .scaleAspectFill
        return imgV
    }()
    
    fileprivate lazy var placeholder: UIImageView = {
       let imgV = UIImageView()
        imgV.image = #imageLiteral(resourceName: "yaofan")
        imgV.contentMode = .center
        return imgV
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.addSubview(self.imageView)
        self.imageView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
    
    var model: ImageListModel? {
        didSet {
            guard let model = model else {
                return
            }
            imageView.image = nil
            imageView.kf.setImage(urlString: model.location, placeholder: placeholder as? Placeholder)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
